#include <cstdio>
using namespace std;

struct link_list {
	int d;
	link_list *next;
};

typedef link_list* link;
typedef link_list Lnode;

link head;

int main() {
	head = new Lnode;
	link p = head;
	int n, m;
	scanf("%d %d", &n, &m);
	if (m == 1) {
		for (int i = 1; i <= n; ++i) printf("%d ", i);
		return 0;
	}
	for (int i = 1; i <= n; ++i) {
		link now = new Lnode;
		now->d = i;
		p->next = now;
		p = now;
	}
	p->next = head->next;
	p = head->next;
	delete head;
	head = p;
	int np = 1;
	while (1) {
		if (p->next == p) {
			printf("%d\n", p->d);
			break;
		} else {
			if (np + 1 == m) {
				link a = p->next;
				p->next = a->next;
				printf("%d ", a->d);
				delete a;
				p = p-
				np = 1;
			} else {
				++np;
				p = p->next;
			}
		}
	}
	return 0;
}
